package com.eden.util;

public class TypeConvertUtil {
	public static double toDouble(Object value){
		if(value == null) return 0 ;
		try {
			if(value instanceof String){
				return Double.valueOf((String) value) ;
			} else if(value instanceof Number) {
				return ((Number)value).doubleValue() ;
			} else {
				return Double.valueOf(value.toString());
			}
		} catch (NumberFormatException e) {
			e.printStackTrace() ;
		} catch(Exception e) {
			e.printStackTrace() ;
		}
		return 0 ;
	}
	
	public static String toStr(Object value) {
		if(value == null) return "" ;
		else {
			return value.toString() ;
		}
	}
}
